set.seed(8487264)
snpF <- 0.41
NN <- 100
pop <- tibble("C1" = rbinom(NN, 1, snpF),
"C2" = rbinom(NN, 1, snpF))
newF <- mean(c(pop$C1, pop$C2))
newF[1] 0.445
Beyond only sampling error
ngen <- 10
npops <- 1000
snpG <- rep(snpF, npops)
output <- matrix(NA, ngen+1, npops)
output[1,] <- snpG
for(gg in 1:ngen){
snpG <- sapply(snpG, function(x) mean(rbinom(NN*2,1,x)))
output[(gg+1),] <- snpG
}
allD <- abs(apply(combn(output[(ngen + 1),],2), 2, diff))
allD |>
tibble() |>
ggplot(aes(allD)) +
geom_histogram(fill = "grey75") +
xlab("Allele Frequency Difference")